home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 351-375 / 351 / pdc / pdcsrc.lzh / PDC / InitAuto.c < prev    next >
C/C++ Source or Header  |  1990-04-06  |  2KB  |  76 lines

  1.  
  2. /* PDC Compiler - A Freely Distributable C Compiler for the Amiga
  3.  *                Based upon prior work by Matthew Brandt and Jeff Lydiatt.
  4.  *
  5.  * PDC Compiler release 3.3 Copyright (C) 1989 Paul Petersen and Lionel Hummel.
  6.  * PDC Software Distribution (C) 1989 Lionel Hummel and Paul Petersen.
  7.  *
  8.  * This code is freely redistributable upon the conditions that this 
  9.  * notice remains intact and that modified versions of this file not be 
  10.  * distributed as part of the PDC Software Distribution without the express
  11.  * consent of the copyright holders.
  12.  *
  13.  *------------------------------------------------------------------
  14.  *
  15.  * $Log:    InitAuto.c,v $
  16.  * Revision 3.33  90/04/05  23:05:21  lionel
  17.  * None.
  18.  * 
  19.  * Revision 3.32  90/02/03  16:24:45  lionel
  20.  * None
  21.  * 
  22.  *------------------------------------------------------------------
  23.  */
  24.  
  25. /* InitAuto.c
  26.  *
  27.  * Generate and initialize a node for an auto initialized variable.
  28.  */
  29.  
  30. #include        <stdio.h>
  31. #include        "C.h"
  32. #include        "Expr.h"
  33. #include        "Gen.h"
  34. #include        "Cglbdec.h"
  35.  
  36. extern char    *xalloc();
  37. extern SYM     *gsearch();
  38. extern long     intexpr(), stringlit();
  39. extern TYP     *exprnc(), *asforcefit(), *deref();
  40. extern struct enode *makenode();
  41. extern struct amode *gen_expr();
  42.  
  43. doinitauto(sp)
  44.     SYM            *sp;
  45. {
  46.     TYP            *tp1, *tp2;
  47.     struct enode   *ep1, *ep2;
  48.     struct snode   *snp;
  49.  
  50.     if (lastst != assign || sp->storage_class != sc_auto)
  51.         return;
  52.  
  53.     getsym();       /* We found an auto initilized variable */
  54.  
  55.     snp = (struct snode *) xalloc(sizeof(struct snode));
  56.     snp->stype = st_expr;
  57.  
  58.     ep1 = makenode(en_autocon, sp->value.i, NULL);
  59.     ep1->constflag = 0;
  60.  
  61.     tp1 = sp->tp;
  62.     tp1 = deref(&ep1, tp1);
  63.  
  64.     tp2 = exprnc(&ep2);
  65.  
  66.     if (tp2 == 0 || !lvalue(ep1))
  67.         error(ERR_LVALUE);
  68.     else {
  69.         tp1 = asforcefit(&ep1, tp1, &ep2, tp2);
  70.         ep1 = makenode(en_assign, ep1, ep2);
  71.         snp->exp = ep1;
  72.         snp->next = NULL;
  73.         addauto(snp);
  74.     }
  75. }
  76.